package com.atguigu.flink.splitAndUnionStream;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class UnionStreamExample {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> ds1 = env.socketTextStream("hadoop102", 8888);
        DataStreamSource<String> ds2 = env.socketTextStream("hadoop102", 8889);
        //DataStreamSource<Integer> integerDataStreamSource = env.fromElements(1, 2, 3, 4);

        // 合流（数据类型必须一致）
        DataStream<String> unionDS = ds1.union(ds1);

        unionDS.print();

        env.execute();
    }
}
